Error : class { // Like exceptions, but without the annoying backtrace :p
    message : String
    throw : func {
        ("[Fatal Error]: " + message) println()
        "Aborting" println()
        exit(1)
    }
}


ArgumentsLessThanError : class extends Error {
    init : func(fName : String, got,expected : Int,line : UInt) {
        message = "Function " + fName +" needs at least " + expected toString() + " arguments, got " + got toString() +" at line " + line toString() + "."
    }
}

ArgumentsLessThanMoreThanError : class extends Error {
    init : func(fName : String, ibound,obound,got : Int,line : UInt) {
        message = "Function " + fName +" needs between " + ibound toString() + " and " + obound toString() +" arguments, got " + got toString() + " at line " + line toString() + "."
    }
}

ArgumentsNotEqualToError : class extends Error {
    init : func(fName : String, expected,got : Int,line : UInt) {
        message = "Function/Macro " + fName+ " needs exactly " + expected toString() + " arguments, got " + got toString() + " at line " + line toString() + "."
    }
}

ArgumentTypeExpectedError : class extends Error {
    init : func(fName : String, argNum : Int, expected,got : Class,line : UInt) {
        message = "Argument " + argNum toString() + " of function " + fName + " was expected of class " + expected name + " but was found to be of class " + got name + " at line " + line toString() + "."
    }
}

RedefinitionError : class extends Error {
    init : func(symbol : String, line : UInt) {
        message = "Attempt to redefine symbol " + symbol + " at line " + line toString() + ". Try to (set) or (fset) instead."
    }
}

UndefinedError : class extends Error {
    init : func(symbol : String, line : UInt) {
        message = "Attempt to access the undefined symbol " + symbol +" at line " + line toString() + ". Try to define it before."
    }
}

UncallableError : class extends Error {
    init : func(element : String, type : Class, line : UInt) {
        message = "Element " + element + " cannot be called, as it is of type " + type name + " at line " + line toString() + "."
    }
}

InvalidIntegerError : class extends Error {
    init : func(inte : String, line : UInt) {
        message = "Invalid or malformed integer literal : " + inte + " on line " + line toString() + "."
    }
}

InvalidDoubleError : class extends Error {
    init : func(dou : String, line : UInt) {
        message = "Invalid or malformed double literal : " + dou + " on line " + line toString() + "."
    }
}

MisplacedParenthesisError : class extends Error {
    init : func (line : UInt) {
        message = "Misplaced parenthesis on line " + line toString()+ "."
    }
}

MalformedLiteralError : class extends Error {
    init : func ~reason (literal,notFound : String, line : UInt) {
        message = "Malformed " + literal + " literal, expected " + notFound + " before end of file on line " + line toString() + "."
    }
    
    init : func ~onlytype (literal : String, line : UInt) {
        message = "Malformed " + literal + " on line " + line toString() + "."
    }
}

OutOfContextError : class extends Error {
    init : func(what,where : String,line : UInt) {
        message = what + " is out of context, should be preceded by " + where + " on line " + line toString() + "."
    }
}
